package com.example.day14_gifloadofc;

import android.graphics.Bitmap;

/**
 * Description:
 * Created by Xzhi on 2020/12/2 17:06.
 */

class GifHandler
{
    Long gifHandler;//C里面的地址  指针

    static {
        System.loadLibrary("native-lib");
    }

    public int getWidth(){
        return getWidth(gifHandler);
    }
    public int getHeight(){
        return getHeight(gifHandler);
    }
    public int updateFrame(Bitmap bitmap){
        return updateFrame(gifHandler,bitmap);
    }

    private GifHandler(Long gitHandler){
        this.gifHandler = gitHandler;
    }

    public static GifHandler load(String path){
        long gifHan = loadGif(path);
        GifHandler handler = new GifHandler(gifHan);
        return handler;
    }

    //开始加载gif图
    public static native long loadGif(String path);
    //获取图片宽
    public static native int getWidth(long gifHandler);
    //获取图片高
    public static native int getHeight(long gifHandler);
    //渲染图片
    public static native int updateFrame(long gifHandler, Bitmap bitmap);


}
